#ifndef GAMETD_MAP_H
#define GAMETD_MAP_H

#include "SDL.h"
#include <string>
#include <fstream>
#include <sstream>
#include <unordered_map>
#include "Tile.h"
#include "Router.h"

class Map {
public:
    typedef std::unordered_map<int, Router> SpawnerRouterPool;

    Map() = default;
    ~Map() = default;
    bool Load(const std::string &path);
    size_t GetWidth() const;
    size_t GetHeight() const;
    const TileMap &GetTileMap() const;
    const SDL_Point &GetIdxHome() const;
    const SpawnerRouterPool &GetSpawnerRouterPool() const;
    void PlaceTower(const SDL_Point &idxTile);

private:
    static std::string TrimStr(const std::string &str);
    static void LoadTileFromString(Tile &tile, const std::string &str);
    void GenerateMapCache();

private:
    TileMap tileMap;
    SDL_Point idxHome = {0};
    SpawnerRouterPool spawnerRouterPool;
};

#endif // GAMETD_MAP_H
